

EndGame = Class.extend({

    init: function (context, id, points) {

        this.context = context;
        this.id = id;
        this.points = points;
        
        this.daRequest();
        
        this.drawEnd();
    },
    
    drawEnd : function (){
        var self = this;
        
        self.context.save();
        self.context.fillStyle = "white";                        
        self.context.shadowColor = '#000';
        self.context.font ="40px Impact, fantasy";
        
        self.context.fillText("You finished with score: "+ self.points,280,300);
        document.onmousedown = function () {
            
        };
    },
    drawImages : function (image,sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
        this.context.drawImage(image,
                            sx, sy,
                            sWidth,sHeight,
                            dx, dy,
                            dWidth, dHeight);
    },
    
    daRequest : function() {
    	console.log(this.id);
    	var url = 'http://ittalentsapi.bashibozuk.eu/game/game-end?id='+this.id+'&X-GameID=102&score='+this.points;
    	console.log(url);
		$.ajax(url, {
			method: 'GET',
			crossDomain : true,
			success: function(data) {
				console.log('4');
				console.log(data);
				console.log('tova')
			}
		});
    }
    
});


